package com.sz.sboot.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration //表示这是一个配置的工具类
@EnableSwagger2
public class SwaggerConfig {

    @Bean //将此方法的返回值添加到spring容器中,ID就是方法名
    public Docket buildDocker(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("易大师")
                .apiInfo(buildApiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.sz.sboot.controller"))
                .paths(PathSelectors.any()).build();
    }

    @Bean
    public Docket buildDocker2(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("钱大师");
    }

    @Bean
    public Docket buildDocker3(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("汪大师");
    }

    private ApiInfo buildApiInfo() {
        return new ApiInfoBuilder().title("深圳市鸿远互联网技术有限公司集成SwaggerUI框架!")
                .description("深圳市鸿远互联网技术有限公司集成SwaggerUI框架!")
                .termsOfServiceUrl("http://www.baidu.com")
                .contact(new Contact("TonyMin","http://www.tonymin.com.cn","447238727@qq.com"))
                .version("1.0")
                .build();
    }
}
